﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;
using System.Collections.ObjectModel;

namespace Biosek
{
	/// <summary>
	/// Hash set of Byte Arrays
	/// </summary>
	public partial class ByteArraySet : HashSet<byte[]>
	{
		/// <summary>
		/// Default constructor
		/// </summary>
		public ByteArraySet()
			: base(ByteArrayEqualityComparer.Instance)
		{
		}

		/// <summary>
		/// Constructor from collection
		/// </summary>
		/// <param name="array"></param>
		public ByteArraySet(IEnumerable<byte[]> array)
			: base(array, EqualityComparer)
		{
		}

		/// <summary>
		/// Default Equality comparer for ByteArraySet
		/// </summary>
		public static ByteArrayEqualityComparer EqualityComparer { get { return ByteArrayEqualityComparer.Instance; } }
	}
		
	public static class SequenceHelper
	{
		/// <summary>
		/// Convert sequence of bytes to array of integer array
		/// </summary>
		/// <param name="set"></param>
		/// <returns></returns>
		public static int[][] ToIntegerArrays(this ISet<byte[]> set)
		{
			var r = set.Select(x => x.Select(y => (int)y).ToArray()).ToArray();
			return r;
		}
	}
}
